

<%--
 ~ A faces page which passes the information retrieved from the params on the URL (name and
 ~ confirmation code) to the ConfirmUserBean to verify the user.
 ~ The odd use of JavaScript is required for two reasons:
 ~ 1.) We don't want the user to actually have to click anything; navigating to the page should suffice.
 ~ 2.) The JavaScript 'form.submit()' call does not submit a form in exactly the same
 ~     fashion as a click event. So we have to simulate a click event.
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<f:view>
    <html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>TestFire</title>
        <jsp:useBean id="nav" class="org.testfire.realm.control.NavBean"/>
        <link rel=stylesheet href="${nav.href_css_basic}" type="text/css">
        <script type="text/javascript" src="${nav.href_js_displayTools}"></script>
        <script type="text/javascript">
            window.onload = validate;

            /**
            * Get the data from the paramaters passed in on the URL.
            * User should have clicked a link in their e-mail which
            * contains 'user' and 'confirmCode' as parameters on the
            * URL, in the form:
            *  http://root.com/login/confirm.jsf?user=username&confirmCode=aConfirmCode
            */
            function validate() {
                var frm = document.getElementById('form_validate');
                var fieldUserName = document.getElementById('form_validate:userName');
                var fieldConfirmCode = document.getElementById('form_validate:confirmCode');
                fieldUserName.value = '${param.user}';
                fieldConfirmCode.value = '${param.confirmCode}';
                var btnSubmit = document.getElementById('form_validate:submit_btn');
                fireCommand(btnSubmit);
            }
        </script>

    </head>
    <body>
    <div id="masthead">
        <h1 id="siteName">TestFire </h1>

        <div id="globalNav">
            <h:form id="form_validate">
                <h:inputHidden id="userName" value="#{ConfirmUserBean.userName}"/>
                <h:inputHidden id="confirmCode" value="#{ConfirmUserBean.confirmCode}"/>
                <div style="display:'none'">
                    <h:commandButton id="submit_btn" value="Confirm" action="#{ConfirmUserBean.confirmUser}"/>
                </div>

            </h:form>

        </div>
    </div>
    <!-- end masthead -->
    <h2 id="pageName">Your Home Page</h2>


    </body>
    </html>
</f:view>
